﻿Imports System.Runtime.CompilerServices
Imports System.Linq.Expressions

Namespace SchoolClick.Helpers
    Public Module HelperExtensor
        <Extension()> _
        Public Function DefinirSubMenuSelected(helper As HtmlHelper, IDSubMenu As Integer) As MvcHtmlString
            Dim strBuilder As New StringBuilder
            strBuilder.Append("<script type=""text/javascript"">") _
                .Append("$(function () {") _
                .Append(String.Format("$('#jerti-subnav').attr('data-active',{0});", IDSubMenu.ToString)) _
                .Append("});") _
                .Append("</script>")
            Return MvcHtmlString.Create(strBuilder.ToString)
        End Function

        <Extension()> _
        Public Function SetMenuActive(helper As HtmlHelper, href As String) As MvcHtmlString
            Dim strBuilder As New StringBuilder
            strBuilder.Append("<script type=""text/javascript"">") _
                .Append("$(function () {") _
                .Append("var $ul = $('#jerti-topnav > div > ul');") _
                .Append("$ul.find('li.active').removeClass('active');") _
                .Append(String.Format("$ul.find('li a[href=""{0}""]').parent().addClass('active');", href)) _
                .Append("});") _
                .Append("</script>")
            Return MvcHtmlString.Create(strBuilder.ToString)
        End Function
    End Module
End Namespace

